import axios from 'axios'
import qs from 'qs'

axios.defaults.timeout = 0;
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8';
axios.defaults.baseURL = 'http://192.168.0.55:8085';

axios.interceptors.request.use(config => {
    if(config.method === 'post'){
        config.data = qs.stringify(config.data)
    }
    return config
},(error) => {
    return Promise.reject(error)
});

axios.interceptors.response.use((response) => {
    return response
},(error) => {
    return Promise.reject(error)
});

class API {
    //登录
    getLogin(param){
        return axios.post('/borrow/user/login', param)
    }
    //登出
    loginOut(param){
        return axios.post('/borrow/user/logout',param)
    }
    //图形验证码
    getCodeImg(){
        return axios.get('/borrow/comm/captcha',{
            params: {
                width: 115,
                height: 36
            },
            responseType:'arraybuffer'
        })
    }
    //获取个人信息
    getHeaderInfo(param){
        return axios.get('/borrow/financier/info',{
            params: param
        })
    }
    //获取账户金额信息
    getAccountInfo(param){
        return axios.get('/borrow/financier/account/info',{
            params: param
        })
    }
    //获取账户流水
    getFlowing(param){
        return axios.get('/borrow/financier/account/flow/info',{
            params: param
        })
    }
    //修改登陆密码
    changePass(param){
        return axios.post('/borrow/user/passwor/update',param)
    }
}

export default API
